Fix OIDC token refresh failing on Windows in the asyncio client - #2668
Merged
kubernetes-prow[bot] merged 1 commit intoAug 5, 2026
Conversation
_refresh_oidc passed the name of an open NamedTemporaryFile to OpenIDRequestor. On Windows the file cannot be reopened by path while the original handle is alive, so any consumer reading the CA cert fails. Add the module-level _create_temp_file_with_content helper, mirroring kubernetes/base/config/kube_config.py, and use it for the CA cert. The FileOrData method now delegates to it, which also closes the descriptor that mkstemp returned. Follow-up to kubernetes-client#2644.
Contributor
Author
|
/kind bug |
Contributor
Author
|
/assign @yliaog |
Contributor
|
thanks for the PR /lgtm |
Contributor
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ealeonraz, yliaog The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
kubernetes-prow
Bot
merged commit Aug 5, 2026
bc2949f
into
kubernetes-client:master
10 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The asyncio client has the same Windows failure as #2644, in a different
form.
_refresh_oidcwrites through the openNamedTemporaryFilehandle,so it avoids the traceback in that PR, but it then passes
certfile.nameto
OpenIDRequestorwhile the handle is still open. On Windows a secondopen of that path fails, so any consumer reading the CA cert by path hits
a PermissionError.
This applies the same fix. The aio module had no module-level
_create_temp_file_with_content, only aFileOrDatamethod, so this addsthe module-level helper mirroring
kubernetes/base/config/kube_config.pyand points the existing method at it, which also closes a descriptor that
mkstempleaked.Note the CA cert temp file now lives until process exit and is cleaned by
the existing
_cleanup_temp_filesatexit hook, matching the sync client,rather than being removed when the
withblock ended.Verified on Windows 11 / Python 3.14:
kubernetes/aio/config/kube_config_test.py: 61 passed.Follow-up to #2644, requested by @yliaog.